package com.bw.zh32301.register

import androidx.lifecycle.MutableLiveData
import com.bw.base.entity.CodeEntity
import com.bw.base.entity.LoginEntity
import com.bw.base.entity.RegisterEntity
import com.bw.base.mvvm.BaseViewModel
import com.bw.base.net.ApiURL
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(val apiURL: ApiURL):BaseViewModel() {
    val loginLiveData= MutableLiveData<LoginEntity>()
    fun login(password:String,username:String){
        httpUtils({apiURL.login(password,username)},loginLiveData::postValue)
    }

    val registerLiveData= MutableLiveData<RegisterEntity>()
    fun register(password:String,username:String){
        httpUtils({apiURL.register(password,username)},registerLiveData::postValue)
    }

    val codeLiveData= MutableLiveData<CodeEntity>()
    fun code(phone:String){
        httpUtils({apiURL.code(phone)},codeLiveData::postValue)
    }
}